package com.crazy.appium.page;

import java.util.List;

import org.openqa.selenium.Point;

import com.crazy.appium.driver.CrazyMobileDriver;

import io.appium.java_client.MobileElement;
import io.appium.java_client.pagefactory.AndroidFindBy;

/**
 * @author 沙陌 qq2879897713
 *
 */
public class LoginPage extends BasePage {
	public MobileElement getLogin_tv() {
		return getElement("loginTv");
	}

	public MobileElement getLogin_phone() {
		return getElement("phone");
	}

	public MobileElement getLogin_pwd() {
		return getElement("passwd");
	}

	public MobileElement getLogin_btn() {
		return getElement("btn_login");
	}
	
	public MobileElement getView_setpasswd() {
		return getElement("View_setpasswd");
	}

	/**
	 * @param driver
	 * @param configfile
	 */
	public LoginPage(CrazyMobileDriver driver, String platform) {
		super(driver, platform);
		// TODO Auto-generated constructor stub
	}
	
	public void inputPhone(String phone){
		getLogin_phone().sendKeys(phone);
	}
	public void inputPWD(String pwd){
		getLogin_pwd().sendKeys(pwd);
	}
	public void clickLoginBtn(){
		getLogin_btn().click();
	}
	//绘制手势锁
	public void setPassword(){
		
		MobileElement element=getView_setpasswd();
		List<Point> coorList=this.driver.getElementByCoordinates(element, 5, 3);
		List<Point> coorListCenter=coorList.subList(3, 12);
		//12589
		int[] pwd={1,2,5,8,9};
		this.driver.wakeByGestures(coorListCenter, pwd);
		this.driver.sleep(1000);
		this.driver.wakeByGestures(coorListCenter, pwd);	
	}

}
